package com.fs.zise;

import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;

import android.graphics.Canvas;
import android.graphics.Paint.Style;

public  class ApplyTool {

//	private int apply_id ;//  唯一ID，不可重复
	private int apply_tool_row;
	private int apply_tool_col;
	private Bitmap bitmap_tool; //工具大图
	
	private Bitmap bitmap_kind_tool;//切割后的小图

	public final static int BUCKET = 83;//水桶
	public final static int MATCHES = 84;//火柴
	public final static int HAMMER = 85;//锤子
	public final static int WRENCH = 86;//扳手
	
	ApplyTool(int apply_tool_row,int apply_tool_col,Bitmap bitmaptool)
	{
		this.setApply_tool_row(apply_tool_row);
		this.setApply_tool_col(apply_tool_col);
		this.bitmap_tool = bitmaptool;
		getWhichToolBitmapByKind();//根据种类切割图片
	}
	
	protected int getApplyKind() {
		return GameMap.getSingleInstance().zise0_map0_one[getApply_tool_row()][getApply_tool_col()];
	}
	
	protected void drawApplyTool(Canvas canvas,Paint paint)
	{
			canvas.save();
			canvas.drawBitmap(bitmap_kind_tool,apply_tool_col* GameMap.getSingleInstance().getCellWidth(), apply_tool_row*GameMap.getSingleInstance().getCellHeight(), paint);
			paint.setColor(Color.BLUE);
			paint.setStyle(Style.STROKE);
			canvas.drawRect(new Rect(apply_tool_col*GameMap.getSingleInstance().getCellWidth(),apply_tool_row*GameMap.getSingleInstance().getCellHeight(),apply_tool_col*GameMap.getSingleInstance().getCellWidth()+GameMap.getSingleInstance().getCellWidth(),apply_tool_row*GameMap.getSingleInstance().getCellHeight()+GameMap.getSingleInstance().getCellHeight()), paint);
			canvas.restore();
	}
	
	public Bitmap getWhichToolBitmapByKind()
	{
		if(getApplyKind() == WRENCH)
			bitmap_kind_tool = Bitmap.createBitmap(bitmap_tool,144,0,48,48);
		else if(getApplyKind() == HAMMER)
			bitmap_kind_tool = Bitmap.createBitmap(bitmap_tool,96,0,48,48);
		else if(getApplyKind() == MATCHES)
			bitmap_kind_tool = Bitmap.createBitmap(bitmap_tool,48,0,48,48);
		else if(getApplyKind() == BUCKET)
			bitmap_kind_tool = Bitmap.createBitmap(bitmap_tool,0,0,48,48);
		
		return bitmap_kind_tool;
	}

	
	public ApplyTool setBitmap_tool(Bitmap bitmap_tool) {
		this.bitmap_tool = bitmap_tool;
		return this;
	}

	public Bitmap getBitmap_tool() {
		return bitmap_tool;
	}

	public ApplyTool setApply_tool_row(int apply_tool_row) {
		this.apply_tool_row = apply_tool_row;
		return this;
	}

	public int getApply_tool_row() {
		return apply_tool_row;
	}

	public ApplyTool setApply_tool_col(int apply_tool_col) {
		this.apply_tool_col = apply_tool_col;
		return this;
	}

	public int getApply_tool_col() {
		return apply_tool_col;
	}

	
}
